package com.example.study.design.factory;

import com.example.study.service.BluetoothKeyServiceImpl;
import com.example.study.service.KeyService;
import com.example.study.service.ShareKeyServiceImpl;
import com.example.study.service.WatchKeyServiceImpl;
import org.springframework.stereotype.Component;

/**
 * 数字钥匙工厂：生成具体的数字钥匙service
 *
 * @author duckquan
 */
@Component
public class KeySimpleFactory {

    /**
     * 获取数字钥匙service实例
     *
     * @param type 类型：1-蓝牙钥匙，2-分享钥匙，3-手表钥匙
     * @return
     */
    public static KeyService getInstance(Integer type) {
        KeyService service = null;
        if (type == 1) {
            service = new BluetoothKeyServiceImpl();
        }
        if (type == 2) {
            service = new ShareKeyServiceImpl();
        }
        if (type == 3) {
            service = new WatchKeyServiceImpl();
        }
        return service;
    }

}
